<template>
  <!--  评论页面         -->
  <el-popover
    placement="right"
    trigger="click">
    <el-button size="mini" icon="el-icon-chat-dot-round" type="info" slot="reference"  @click="findComment">查看评论</el-button>
    <el-table  :data="commentData">
      <el-table-column width="100" property="blogCommentId" label="评论id"></el-table-column>
      <el-table-column width="100"  property="blogCommentIp" label="评论ip地址"></el-table-column>
      <el-table-column width="100"  label="评论时间">

        <template slot-scope="scope">
          {{scope.row.blogCommentTime| dateFormat }}
        </template>

      </el-table-column>
      <el-table-column width="500"  label="内容">

        <template slot-scope="scope">
          <span v-html="scope.row.blogCommentContent"></span>
          <!--               内部可以嵌套html标签   -->
        </template>

      </el-table-column>
      <el-table-column width="100"  property="blogCommentLike" label="喜欢"></el-table-column>
      <el-table-column width="100" label="操作">
        <el-button size="mini" icon="el-icon-delete" type="danger">逻辑删除</el-button>
      </el-table-column>
      <el-table-column width="100"  property="blogCommentDelete" label="是否已删除">

      </el-table-column>

    </el-table>
  </el-popover>
</template>

<script>
import {commentsGet} from "@/api/blog";

export default {
  name: "blogComment",
  props: ['blogId'],
  data() {
    return {
      commentData: []
    }
  },
  methods:{
    findComment(){
      commentsGet(this.blogId).then(res => {
          if (res.code===404){
            this.$message({
              type: 'warning',
              message: res.msg
            })
            this.commentData = '';
          }else {
            this.commentData = res.comment;
          }
        }
      ).catch(err => {
          console.error(err);
        }
      )
    }
  }
}
</script>

<style scoped>

</style>
